<%@ page language="java" import="weaver.common.DateUtil" pageEncoding="UTF-8" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%
    User user = HrmUserVarify.getUser( request, response );
    int userid = user.getUID();
    int docount = getMyListDoing(userid);
    int reqcount = getMyListRequest(userid);
    int workcount = getWorkplan();
%>
<%!
public static int getMyListDoing(int userid){
    RecordSet rs = new RecordSet();
    String sql = "select count(1) from (select  requestid,requestmark,createdate, createtime,creater, " +
            "creatertype, workflowid, requestname, requestnamenew, status,requestlevel," +
            "currentnodeid,viewtype,userid,receivedate,receivetime,isremark," +
            "nodeid,agentorbyagentid,agenttype,isprocessed ,systype,workflowtype," +
            "isbereject,takisremark,requestnamehtmlnew,viewDate,viewTime,lastFeedBackDate," +
            "lastFeedBackTime,needwfback,lastFeedBackOperator " +
            "from (select  t1.requestid,t1.requestmark,t1.createdate, " +
            "t1.createtime,t1.creater, t1.creatertype, t1.workflowid, " +
            "t1.requestname, t1.requestnamenew, t1.status,t1.requestlevel," +
            "t1.currentnodeid,t2.viewtype,t2.userid,t2.receivedate,t2.receivetime," +
            "t2.isremark,t2.nodeid,t2.agentorbyagentid,t2.agenttype,t2.isprocessed  " +
            ",t1.seclevel,'0' as systype,t2.workflowtype,t2.isbereject,t2.takisremark," +
            "t1.requestnamehtmlnew,t2.viewDate,t2.viewTime,t1.lastFeedBackDate," +
            "t1.lastFeedBackTime,t2.needwfback,t1.lastFeedBackOperator  " +
            "from workflow_requestbase t1,workflow_currentoperator t2,workflow_base " +
            "t3 where t1.requestid = t2.requestid and t1.workflowid=t3.id and " +
            "t2.userid in ("+userid+" ) and t2.usertype=0 and (isnull(t1.currentstatus,-1) " +
            "= -1 or (isnull(t1.currentstatus,-1)=0 and t1.creater in ("+userid+")))  " +
            " and (t1.deleted<>1 or t1.deleted is null or t1.deleted='')  " +
            "and ((t2.isremark='0' and (t2.takisremark is null or t2.takisremark=0 )) " +
            "or t2.isremark in('1','5','8','9','7','11')) and t2.islasttimes=1 and " +
            "(isprocessing = '' or isprocessing is null)  and t3.isvalid in('1','3') " +
            " union (select distinct  requestid,'' as requestmark,createdate, " +
            "createtime,creatorid as creater, 0 as creatertype, workflowid, " +
            "requestname, requestname as requestnamenew, '' as status,requestlevel," +
            "-1 as currentnodeid,viewtype,userid,receivedate,receivetime,isremark,0 as nodeid, " +
            "-1 as agentorbyagentid,'0' as agenttype,'0' as isprocessed  ,'4' as secLevel," +
            "'1' as systype, sysid as workflowtype,'' as isbereject,0 as takisremark," +
            "'' as requestnamehtmlnew,'' as viewDate,'' as viewTime,'' as lastFeedBackDate," +
            "'' as lastFeedBackTime,'' as needwfback,0 as lastFeedBackOperator from ofs_todo_data " +
            " where 1=1   and userid in("+userid+") and islasttimes=1 and isremark in(0,8,9)  " +
            "and ofs_todo_data.pcurl is not null  and ofs_todo_data.pcurl <> '' ) ) t1 ) t1 ";
    rs.executeQuery(sql);
    rs.next();
    return Util.getIntValue(rs.getString(1));
}

public static int getMyListRequest(int userid){
    RecordSet rs = new RecordSet();
    String sql = "select count(1) from (select  requestid," +
            "requestmark,createdate, createtime,creater, creatertype, workflowid, " +
            "requestname, requestnamenew, status,requestlevel,currentnodeid,viewtype," +
            "userid,receivedate,receivetime,isremark,nodeid,agentorbyagentid,agenttype," +
            "isprocessed ,systype,workflowtype,isbereject,takisremark,requestnamehtmlnew," +
            "viewDate,viewTime,lastFeedBackDate,lastFeedBackTime,needwfback,lastFeedBackOperator " +
            "from (select  t1.requestid,t1.requestmark,t1.createdate, t1.createtime,t1.creater," +
            " t1.creatertype, t1.workflowid, t1.requestname, t1.requestnamenew, t1.status," +
            "t1.requestlevel,t1.currentnodeid,t2.viewtype,t2.userid,t2.receivedate,t2.receivetime," +
            "t2.isremark,t2.nodeid,t2.agentorbyagentid,t2.agenttype,t2.isprocessed  ,t1.seclevel," +
            "'0' as systype,t2.workflowtype,t2.isbereject,t2.takisremark,t1.requestnamehtmlnew," +
            "t2.viewDate,t2.viewTime,t1.lastFeedBackDate,t1.lastFeedBackTime,t2.needwfback," +
            "t1.lastFeedBackOperator  from workflow_requestbase t1,workflow_currentoperator t2," +
            "workflow_base t3 where t1.requestid = t2.requestid and t1.workflowid=t3.id and " +
            "t2.userid in ("+userid+") and t2.usertype=0 and (isnull(t1.currentstatus,-1) = -1 " +
            "or (isnull(t1.currentstatus,-1)=0 and t1.creater in ("+userid+")))   and (t1.deleted<>1 " +
            "or t1.deleted is null or t1.deleted='')  and t1.creater in ("+userid+") and t1.creatertype = 0 " +
            "and t1.creater = t2.userid  and ((t1.currentnodetype <> '3') " +
            "or (t2.isremark in('1','2','4','5','8','9','11') and t1.currentnodetype = '3' )) " +
            "and t2.islasttimes=1  and t3.isvalid in('1','3')  " +
            "union (select distinct  requestid,'' as requestmark,createdate, createtime," +
            "creatorid as creater, 0 as creatertype, workflowid, requestname, requestname as requestnamenew," +
            " '' as status,requestlevel,-1 as currentnodeid,viewtype,userid,receivedate,receivetime,isremark," +
            "0 as nodeid, -1 as agentorbyagentid,'0' as agenttype,'0' as isprocessed  ,'4' as secLevel," +
            "'1' as systype, sysid as workflowtype,'' as isbereject,0 as takisremark,'' as requestnamehtmlnew," +
            "'' as viewDate,'' as viewTime,'' as lastFeedBackDate,'' as lastFeedBackTime,'' as needwfback," +
            "0 as lastFeedBackOperator from ofs_todo_data  where 1=1   and creatorid in("+userid+") and creatorid=userid " +
            "and islasttimes=1  and isremark in(0,8,9)  and ofs_todo_data.pcurl is not null  and ofs_todo_data.pcurl <> '' ) ) t1" +
            " ) t1";
    rs.executeQuery(sql);
    rs.next();
    return Util.getIntValue(rs.getString(1));

}

public static int getWorkplan(){
    String curdate = DateUtil.getCurrentDate();
    RecordSet rs = new RecordSet();
    String sql = "select count(1) from WorkPlan workPlan, (SELECT workId,max(shareLevel) as shareLevel " +
            "from (  select workId,shareLevel from WorkPlanShareDetail where (objId = 1 and usertype = 1 " +
            "and shareType = '1' and securityLevel = 0 and securityLevelMax = 0)  " +
            "union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 1 and usertype = 1 and shareType = '6' and securityLevel = 0 " +
            "and securityLevelMax = 0)  union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 1 and usertype = 1 and shareType = '7' and securityLevel = 0 and " +
            "securityLevelMax = 0)  union all select workId,shareLevel from WorkPlanShareDetail " +
            " where (objId = 0 and usertype = 1 and shareType = '5' and  securityLevel<=30 and  " +
            "securityLevelMax>=30)  union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId in (0) and usertype=1 and shareType='2' and  securityLevel<=30 and  " +
            "securityLevelMax>=30)  union all select workId,shareLevel from WorkPlanShareDetail " +
            " where (objId in (0) and usertype=1 and shareType='3' and  securityLevel<=30 and  " +
            "securityLevelMax>=30)  union ALL SELECT workId,shareLevel from WorkPlanShareDetail " +
            "WHERE usertype = 1 AND shareType = '8' AND objId = '' AND ( joblevel = 0 " +
            "OR ( joblevel = 1 AND joblevelvalue in (0) ) OR ( joblevel = 2 AND joblevelvalue in (0)))" +
            " union all select workId,shareLevel from WorkPlanShareDetail  where (objId = 1 and " +
            "usertype=1 and shareType='4' and  securityLevel<=30 and  securityLevelMax>=30 " +
            "and 2>=rolelevel )  union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 2 and usertype=1 and shareType='4' and  securityLevel<=30 and  " +
            "securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 3 and usertype=1 and shareType='4' and  securityLevel<=30 and  securityLevelMax>=30 " +
            "and 2>=rolelevel )  union all select workId,shareLevel from WorkPlanShareDetail " +
            " where (objId = 4 and usertype=1 and shareType='4' and  securityLevel<=30 and  " +
            "securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel from WorkPlanShareDetail" +
            "  where (objId = 5 and usertype=1 and shareType='4' and  securityLevel<=30 and  securityLevelMax>=30 " +
            "and 2>=rolelevel )  union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 6 and usertype=1 and shareType='4' and  securityLevel<=30 and " +
            " securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel " +
            "from WorkPlanShareDetail  where (objId = 7 and usertype=1 and shareType='4' and " +
            " securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel )  " +
            "union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 8 and usertype=1 and shareType='4' and  securityLevel<=30 and  " +
            "securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel " +
            "from WorkPlanShareDetail  where (objId = 9 and usertype=1 and shareType='4' and " +
            " securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel )  " +
            "union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 10 and usertype=1 and shareType='4' and  securityLevel<=30 and " +
            " securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel " +
            "from WorkPlanShareDetail  where (objId = 11 and usertype=1 and shareType='4' and " +
            " securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel )  " +
            "union all select workId,shareLevel from WorkPlanShareDetail  where (objId = 12 " +
            "and usertype=1 and shareType='4' and  securityLevel<=30 and  securityLevelMax>=30 " +
            "and 2>=rolelevel )  union all select workId,shareLevel from WorkPlanShareDetail " +
            " where (objId = 13 and usertype=1 and shareType='4' and  securityLevel<=30 and " +
            " securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel from " +
            "WorkPlanShareDetail  where (objId = 14 and usertype=1 and shareType='4' and  " +
            "securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel )  " +
            "union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 15 and usertype=1 and shareType='4' and  securityLevel<=30 and  " +
            "securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel " +
            "from WorkPlanShareDetail  where (objId = 16 and usertype=1 and shareType='4' and " +
            " securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel )  " +
            "union all select workId,shareLevel from WorkPlanShareDetail  where (objId = 17 and usertype=1" +
            " and shareType='4' and  securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel )  " +
            "union all select workId,shareLevel from WorkPlanShareDetail  where (objId = 18 and " +
            "usertype=1 and shareType='4' and  securityLevel<=30 and  securityLevelMax>=30 and " +
            "2>=rolelevel )  union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 19 and usertype=1 and shareType='4' and  securityLevel<=30 and  " +
            "securityLevelMax>=30 and 2>=rolelevel )  union all select workId,shareLevel from " +
            "WorkPlanShareDetail  where (objId = 20 and usertype=1 and shareType='4' and  " +
            "securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel )  union all select " +
            "workId,shareLevel from WorkPlanShareDetail  where (objId = 21 and usertype=1 and " +
            "shareType='4' and  securityLevel<=30 and  securityLevelMax>=30 and 2>=rolelevel ) " +
            " union all select workId,shareLevel from WorkPlanShareDetail  " +
            "where (objId = 22 and usertype=1 and shareType='4' and  securityLevel<=30 and " +
            " securityLevelMax>=30 and 2>=rolelevel ) ) st1  group by st1.workId) workPlanShareDetail " +
            " where workPlan.ID = workPlanShareDetail.workID  and ( " +
            " (  (workplan.endDate > '"+curdate+"' or ( workplan.endDate = '"+curdate+"' and " +
            "workplan.endtime >= '00:00' ) )  and ( workplan.beginDate < '"+curdate+"' or ( workplan.beginDate = '"+curdate+"' " +
            "and workplan.beginTime <='23:59' ))  )  or (  (len(workplan.endDate)=0  " +
            "AND ( workplan.beginDate > '"+curdate+"' or ( workplan.beginDate = '"+curdate+"' " +
            "and workplan.beginTime >='00:00' )) ) )  )";
    rs.executeQuery(sql);
    rs.next();
    return Util.getIntValue(rs.getString(1));
}
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css"/>
</head>
<style>
    .div1{background-color: rgb(61, 161, 236);width:100%;height: 100%;float:right;margin-right:30px;padding:30px;border-radius: 8px;}
    .div2{background-color: rgb(226, 146, 16);width:100%;height: 100%;float:left;margin-right:30px;padding:30px;border-radius: 8px;}
    .div3{background-color: rgb(88, 211, 75);width:100%;height: 100%;float:left;margin-left:30px;padding:30px;border-radius: 8px;}


    .div1 .div2 .div3 span {
        width: 40px;
        height: 0px;
        /* 设置盒子为行内块 */
        display: inline-block;
        background-color: skyblue;
        /* 设置盒子内元素水平居中 */
        text-align: center;
        /* 设置盒子内容垂直居中 */
        line-height: 40px;
    }

</style>
<body style="height: 100%;width:100%;margin-top: 1%">
<table style="margin: auto;">
    <tr>
        <td><div class="div1">
            <a style="float: left;width: max-content;color: cyan;text-decoration:none;" href="/wui/index.html#/main/workflow/listDoing?menuIds=1,13&menuPathIds=1,13" target="_blank"><h4>我的待办</h4></a>
            <span style="float: right;width: max-content;color: cyan;"><h4><%=docount%></h4></span>
        </div></td>
        <td><div class="div2">
            <a style="float: left;width: max-content;color: cyan;text-decoration:none;" href="/wui/index.html#/main/workflow/listMine?menuIds=1,14&menuPathIds=1,14" target="_blank"><h4>我的流程</h4></a>
            <span style="float: right;width: max-content;color: cyan;"><h4><%=reqcount%></h4></span>
        </div></td>
        <td><div class="div3">
            <a style="float: left;width: max-content;color: cyan;text-decoration:none;" href="/wui/index.html#/main/wp/myWorkPlan?menuIds=140,60&menuPathIds=140,60" target="_blank"><h4>我的日程</h4></a>
            <span style="float: right;width: max-content;color: cyan;"><h4><%=workcount%></h4></span>
        </div></td>
    </tr>
</table>
</body>
</html>



